<script setup>
import { ref } from 'vue'

defineProps({
  msg: {
    type: String,
    required: true
  },
  name: String
})

const age = ref(20)

// 自定义事件
const emits = defineEmits(['e-age'])

const sendData = function(){  
  // 触发事件，传递数据
  emits('e-age',age.value)
}

</script>

<template>
  <h1>{{ msg }}, {{ name }}</h1>

  <button @click="sendData">向父组件传递数据</button>

</template>

<style scoped>

</style>
